package com.jingbian.cppccbackend.service.impl.user;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jingbian.cppccbackend.entity.ActivityOutcomes;
import com.jingbian.cppccbackend.entity.dto.ActivitysOutcomesListDTO;

import com.jingbian.cppccbackend.mapper.user.ActivityOutcomesMapper;
import com.jingbian.cppccbackend.service.user.IActivityOutcomesService;
import com.jingbian.cppccbackend.vo.ActivitiesOutcomesDetailVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 活动成果表 服务实现类
 * </p>
 *
 * @author pum
 * @since 2025-03-01
 */
@Service
public class ActivityOutcomesServiceImpl extends ServiceImpl<ActivityOutcomesMapper, ActivityOutcomes> implements IActivityOutcomesService {

  @Autowired
  private ActivityOutcomesMapper activityOutcomesMapper;

  @Override
  public void publishOutcomes(ActivityOutcomes activityOutcomes) {
    activityOutcomes.setCreatedAt(LocalDateTime.now());
    activityOutcomes.setUpdatedAt(LocalDateTime.now());
    activityOutcomesMapper.insertOutcomes(activityOutcomes);
  }

  @Override
  public PageInfo<ActivityOutcomes> geOutcomestList(ActivitysOutcomesListDTO activitysOutcomesListDTO) {
    PageHelper.startPage(activitysOutcomesListDTO.getPageNum(), activitysOutcomesListDTO.getPageSize());
    List<ActivityOutcomes> list = activityOutcomesMapper.getOutcomesList(activitysOutcomesListDTO);
    return new PageInfo<>(list);
  }

  @Override
  public ActivitiesOutcomesDetailVO getOutcomesDetail(Integer oid) {
    return activityOutcomesMapper.getOutcomesDetail(oid);
  }
}
